<?php

/**
 * @see Zend_Filter_Interface
 */
require_once 'Zend/Filter/Interface.php';


/**
 * Dekoduje ID
 *
 * @category   Core
 * @package    Core_Filter
 * @copyright  Copyright (c) 2008 Kuśmierz Adam
 * @author Adam Kuśmierz
 */
class Core_Filter_DecodeID implements Zend_Filter_Interface
{
	/**
	 * Defined by Zend_Filter_Interface
	 *
	 * Returns (int) $value
	 *
	 * @param  string $value
	 * @return integer
	 */
	public function filter($value)
	{
		$value = (string) $value;
		
		if (!preg_match('#^[a-z0-9]{8}$#', $value))
			return false;
		
		$value = base_convert($value, 36, 10);
		$value = intval(substr($value, 2));
		return $value;
	}
}
